User Identification in Events
How to Cross-Reference Information to Identify the User
In many operational scenarios, identifying the user responsible for an event is essential for analysis, contextual actions, and auditing. Below, we list possible approaches to perform this identification based on secure technical practices compatible with privacy guidelines.
1 - Using notificationToken:
This function expects a String parameter, which represents the user's notification token. On iOS, this token is provided by APNS (Apple Push Notification Service), while on Android, it is obtained through Firebase Cloud Messaging.
Before using the method related to notificationToken
, make sure you have correctly followed all the steps in the push notification setup guide. This ensures that the services are properly configured and that the token can be retrieved and used without issues.
To obtain the notification token, you’ll need to implement two new functions in the UIApplicationDelegate
. The function didRegisterForRemoteNotificationsWithDeviceToken
, if the user accepts the permission, and didFailToRegisterForRemoteNotificationsWithError
if the user declines.
If permission is granted, you will call the sendNotificationToken
function from the Group Link SDK.
Swift Implementation
func application(_ application: UIApplication,
didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
let tokenParts = deviceToken.map { data in String(format: "%02.2hhx", data) }
let token = tokenParts.joined()
GroupLinkSDK.sendNotificationToken(token)
}
func application(_ application: UIApplication,
didFailToRegisterForRemoteNotificationsWithError error: Error) {
print("Error getting notification token: \(error)")
}
Objective-C Implementation
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
NSUInteger dataLength = deviceToken.length;
if (dataLength == 0) {
return;
}
const unsigned char *dataBuffer = (const unsigned char *)deviceToken.bytes;
NSMutableString *token = [NSMutableString stringWithCapacity:(dataLength * 2)];
for (int i = 0; i < dataLength; ++i) {
[token appendFormat:@"%02x", dataBuffer[i]];
}
[GroupLinkSDK sendNotificationToken:token];
}
- (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error {
NSLog(@"Error getting token:%@", error);
}